
export const debounce = (fn:any,timerDelay:number) => {
    timerDelay = timerDelay || 300
    let timer:any
    return function(){
        let that:any = this
        let params:any = arguments
        if(timer) clearTimeout(timer)
        timer = setTimeout(() => {
            fn.apply(that,params)
        },timerDelay)
    }
}

/**
 * 判断是否有值，0不发生转换，数字0和字符串0都是false，即 不为空
 * 空数组也返回true，即为空
 * @param v
 * @returns {boolean}
 */
export const isEmpty = (v:any):boolean => {
    switch (typeof v) {
        case 'undefined':
            return true;
        case 'string':
            if (v.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
            break;
        case 'boolean':
            if (!v) return true;
            break;
        case 'number':
            if (isNaN(v)) return true; // 0不发生转换，数字0和字符串0都是false，即 不为空
            break;
        case 'object':
            if (null === v || v.length === 0) return true;
            for (var i in v) {
                return false;
            }
            return true;
    }
    return false;
}

export const mapArray = (array:Array<Object>) => {
    for(let i:number = 0 ; i < array.length ; i++ ){
        console.log(array[i])
    }
    return array.length
}
//
// export function mapArray(){
//     console.log(123)
// }

// 获取面积下拉列表
export const proportionOptions = ():Array<Object> => {
    let data = [
        {
            value: '1',
            label: '1'
        }, {
            value: '2',
            label: '2'
        }, {
            value: '3',
            label: '3'
        }, {
            value: '4',
            label: '4'
        }, {
            value: '5',
            label: '5'
        }, {
            value: '6',
            label: '6'
        }, {
            value: '7',
            label: '7'
        }, {
            value: '8',
            label: '8'
        }, {
            value: '9',
            label: '9'
        }, {
            value: '10',
            label: '10'
        }, {
            value: '11',
            label: '11'
        }, {
            value: '12',
            label: '12'
        }, {
            value: '13',
            label: '13'
        }, {
            value: '14',
            label: '14'
        }, {
            value: '15',
            label: '15'
        }, {
            value: '16',
            label: '16'
        }, {
            value: '0.016',
            label: '1/64'
        }, {
            value: '0.031',
            label: '1/32'
        }, {
            value: '0.062',
            label: '1/16'
        }, {
            value: '0.083',
            label: '1/12'
        }, {
            value: '0.091',
            label: '1/11'
        }, {
            value: '0.1',
            label: '1/10'
        }, {
            value: '0.111',
            label: '1/9'
        }, {
            value: '0.125',
            label: '1/8'
        }, {
            value: '0.375',
            label: '3/8'
        }, {
            value: '0.625',
            label: '5/8'
        }, {
            value: '0.875',
            label: '7/8'
        }, {
            value: '0.143',
            label: '1/7'
        }, {
            value: '0.286',
            label: '2/7'
        }, {
            value: '0.429',
            label: '3/7'
        }, {
            value: '0.571',
            label: '4/7'
        }, {
            value: '0.714',
            label: '5/7'
        }, {
            value: '0.857',
            label: '6/7'
        }, {
            value: '0.167',
            label: '1/6'
        }, {
            value: '0.83',
            label: '5/6'
        }, {
            value: '0.2',
            label: '1/5'
        }, {
            value: '0.4',
            label: '2/5'
        }, {
            value: '0.6',
            label: '3/5'
        }, {
            value: '0.8',
            label: '4/5'
        }, {
            value: '0.25',
            label: '1/4'
        }, {
            value: '0.75',
            label: '3/4'
        }, {
            value: '0.333',
            label: '1/3'
        }, {
            value: '0.667',
            label: '2/3'
        }, {
            value: '0.5',
            label: '1/2'
        }
    ]
    return data
}

